Skip to content

Conversation

@Mnehmos
Copy link
Contributor

@Mnehmos Mnehmos commented Jun 6, 2025

Related GitHub Issue

Closes: #2579

Description

This pull request re-implements the changes from the original PR #4371.

This PR addresses issue #2579, which pointed out confusing UI behavior in the auto-approve feature. The changes ensure that the UI state is always clear and unambiguous to the user.

The primary changes are:

  • webview-ui/src/components/chat/AutoApproveMenu.tsx:
    • The main "Auto-Approve" checkbox is now disabled when no individual actions are approved.
    • Enabling an individual action now automatically enables the main auto-approve setting.
  • webview-ui/src/components/settings/AutoApproveToggle.tsx:
    • The toggle buttons now correctly reflect their individual state while also visually indicating whether the overall auto-approve setting is enabled.
  • .gitignore:
    • Added webview-ui/node_modules and webview-ui/dist to the ignore list.

These changes ensure that the user's preference is respected, improving the overall user experience.

Test Procedure

  1. Go to the chat view.
  2. Open the Auto-approve menu.
  3. Verify the main checkbox is disabled when no options are selected.
  4. Select an option (e.g., "Read-Only").
  5. Verify the main checkbox becomes checked.
  6. Uncheck all options.
  7. Verify the main checkbox becomes unchecked and disabled.
  8. Collapse the menu with an option selected.
  9. Verify the checkbox is checked and the selected option is displayed.
  10. Uncheck the checkbox in the collapsed state.
  11. Verify the text changes to "None".

Type of Change

  • 🐛 Bug Fix: Non-breaking change that fixes an issue.
  • New Feature: Non-breaking change that adds functionality.
  • 💥 Breaking Change: Fix or feature that would cause existing functionality to not work as expected.
  • ♻️ Refactor: Code change that neither fixes a bug nor adds a feature.
  • 💅 Style: Changes that do not affect the meaning of the code (white-space, formatting, etc.).
  • 📚 Documentation: Updates to documentation files.
  • ⚙️ Build/CI: Changes to the build process or CI configuration.
  • 🧹 Chore: Other changes that don't modify src or test files.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Code Quality:
    • My code adheres to the project's style guidelines.
    • There are no new linting errors or warnings (npm run lint).
    • All debug code (e.g., console.log) has been removed.
  • Testing:
    • New and/or updated tests have been added to cover my changes.
    • All tests pass locally (npm test).
    • The application builds successfully with my changes.
  • Branch Hygiene: My branch is up-to-date (rebased) with the main branch.
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Changeset: A changeset has been created using npm run changeset if this PR includes user-facing changes or dependency updates.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Screenshots / Videos

image
image
image
image
image

Documentation Updates

  • No documentation updates are required.

Additional Notes

This PR is a recreation of #4371 after the original branch was accidentally deleted.


Important

Fixes UI behavior in AutoApproveMenu.tsx and AutoApproveToggle.tsx to ensure clear auto-approve state indication and updates .gitignore.

  • Behavior:
    • In AutoApproveMenu.tsx, the main "Auto-Approve" checkbox is disabled when no actions are approved and is automatically enabled when any action is selected.
    • In AutoApproveToggle.tsx, toggle buttons reflect their individual state and indicate if the overall auto-approve setting is enabled.
  • Misc:
    • Added webview-ui/node_modules and webview-ui/dist to .gitignore.

This description was created by Ellipsis for 629aee0. You can customize this summary. It will automatically update as commits are pushed.

This PR addresses issue RooCodeInc#2579, where the auto-approve toast notification would reappear even after the user selected "Don't show again." The root cause was that the user's preference was not being persisted across sessions.
@Mnehmos Mnehmos requested review from cte, jr and mrubens as code owners June 6, 2025 01:41
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working UI/UX UI/UX related or focused labels Jun 6, 2025
@Mnehmos Mnehmos changed the title fix: Prevent auto-approve toast from showing after dismissal fix: Fix Auto Approve UI Closing #2579 Jun 6, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jun 6, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @Mnehmos, Thank you for working on this fix!

I took a look at your PR and left a couple of suggestions that are worth taking a look at.

Let me know if you have any questions!

// If the user unchecks the last enabled option, autoApprovalEnabled should become false.
// This logic is already handled by the main checkbox's disabled state in the collapsed view.
// So, we only need to ensure it turns ON when an individual is turned ON.
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The state synchronization logic here seems complex and the extensive comments suggest uncertainty about the approach. Could we simplify this by creating a more robust state update mechanism?

Specifically, the else branch (lines 84-95) acknowledges that it doesn't handle the case where disabling an action should potentially disable the main checkbox. This could lead to inconsistent UI states.

Consider extracting this logic into a separate function that can properly calculate the new state based on all current toggle values, rather than relying on "future render cycles".

if (value === true) {
setAutoApprovalEnabled(true)
vscode.postMessage({ type: "autoApprovalEnabled", bool: true })
} else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic here only handles enabling the main checkbox when an individual action is enabled, but doesn't handle the reverse case. When the last enabled action is disabled, the main checkbox should also be disabled automatically.

Consider adding logic to check if all toggles are now false and update autoApprovalEnabled accordingly:

if (value === true) {
  setAutoApprovalEnabled(true)
  vscode.postMessage({ type: "autoApprovalEnabled", bool: true })
} else {
  // Check if this was the last enabled toggle
  const updatedToggles = { ...toggles, [key]: false }
  const hasAnyEnabled = Object.values(updatedToggles).some(v => !!v)
  if (!hasAnyEnabled) {
    setAutoApprovalEnabled(false)
    vscode.postMessage({ type: "autoApprovalEnabled", bool: false })
  }
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were these changes accidental?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes yes and yes. This was my first PR attempt, I'll review all of these and come with a much more solid approach. Thank you for reviewing these changes.

@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Changes Requested] in Roo Code Roadmap Jun 8, 2025
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jun 10, 2025
…ssues

- Remove master toggle UI from AutoApproveSettings component
- Remove master toggle translation keys from English locale
- Update tests to remove master toggle functionality
- Fix useDeepCompareEffect warning in ChatView.tsx by using useEffect
- Optimize useAutoApproveState hook for better performance:
  - Improve memoization dependencies
  - Batch state updates in handleMasterToggle
  - Optimize callback dependencies
- Optimize AutoApproveMenu with memoized setters object
- Resolves language check failure in PR RooCodeInc#4395
@daniel-lxs daniel-lxs moved this from PR [Changes Requested] to PR [Needs Prelim Review] in Roo Code Roadmap Jun 11, 2025
@daniel-lxs
Copy link
Member

Hey @Mnehmos, Thank you for taking a look at the suggestions!

I was testing the auto-approve buttons and noticed a weird behavior:

2025-06-11_08-01-55.mp4

It seems like the buttons are enabled or disabled randomly, can you take a look?

@daniel-lxs daniel-lxs marked this pull request as draft June 11, 2025 13:07
@daniel-lxs daniel-lxs moved this from PR [Needs Prelim Review] to PR [Draft / In Progress] in Roo Code Roadmap Jun 11, 2025
@Mnehmos Mnehmos closed this Jun 11, 2025
@github-project-automation github-project-automation bot moved this from PR [Draft / In Progress] to Done in Roo Code Roadmap Jun 11, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jun 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working PR - Draft / In Progress size:XL This PR changes 500-999 lines, ignoring generated files. UI/UX UI/UX related or focused

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

Redesign Auto-approve; don't allow confusing checkbox status with labels

3 participants